package com.office.stacks.circumstance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.enums.BusinessType;
import com.office.stacks.circumstance.domain.Circumstance;
import com.office.stacks.circumstance.service.ICircumstanceService;
import com.office.common.utils.poi.ExcelUtil;
import com.office.common.core.page.TableDataInfo;

/**
 * 任务情况Controller
 * 
 * @author 柒月
 * @date 2025-05-24
 */
@RestController
@RequestMapping("/shape/press")
public class CircumstanceController extends BaseController
{
    @Autowired
    private ICircumstanceService circumstanceService;

    /**
     * 查询任务情况列表
     */
    @PreAuthorize("@ss.hasPermi('shape:press:list')")
    @GetMapping("/list")
    public TableDataInfo list(Circumstance circumstance)
    {
        startPage();
        List<Circumstance> list = circumstanceService.selectCircumstanceList(circumstance);
        return getDataTable(list);
    }

    /**
     * 导出任务情况列表
     */
    @PreAuthorize("@ss.hasPermi('shape:press:export')")
    @Log(title = "任务情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Circumstance circumstance)
    {
        List<Circumstance> list = circumstanceService.selectCircumstanceList(circumstance);
        ExcelUtil<Circumstance> util = new ExcelUtil<Circumstance>(Circumstance.class);
        util.exportExcel(response, list, "任务情况数据");
    }

    /**
     * 获取任务情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('shape:press:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(circumstanceService.selectCircumstanceById(id));
    }

    /**
     * 打回任务情况
     */
    @PreAuthorize("@ss.hasPermi('shape:press:call')")
    @Log(title = "打回任务", businessType = BusinessType.UPDATE)
    @PutMapping("/{id}")
    public AjaxResult add(@PathVariable Long id)
    {
        return toAjax(circumstanceService.callCircumstance(id));
    }

    /**
     * 修改任务情况
     */
    @PreAuthorize("@ss.hasPermi('shape:press:edit')")
    @Log(title = "任务情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Circumstance circumstance)
    {
        return toAjax(circumstanceService.updateCircumstance(circumstance));
    }

    /**
     * 删除任务情况
     */
    @PreAuthorize("@ss.hasPermi('shape:press:remove')")
    @Log(title = "任务情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(circumstanceService.deleteCircumstanceByIds(ids));
    }
}
